//
//  ZQMainPageViewController.m
//  jianzhik
//
//  Created by huami on 2018/8/28.
//  Copyright © 2018年 WKWebView. All rights reserved.
//
#import "ZQFastBtn.h"
#import "ZQKFeeSettingPage.h"
#import "ZQProcessedOrderPage.h"
#import "ZQMoneyManger.h"
#import "ZQAdminSetting.h"
#import "ZQ_GetCurrentViewNavTool.h"
#import "ZQMainPage.h"
#import "UIBarButtonItem+item.h"
#import "ZQMyAdressPage.h"
#import "ZQPendingOrderPage.h"
#import "ZQZZPage.h"
typedef NS_ENUM(NSUInteger, BtnClickType){
    BtnClickTypeS_GLYSZ = 10,
    BtnClickTypeS_BZGL = 11,
    BtnClickTypeS_WDDZ = 12,
    BtnClickType_WDDZ = 13,
    BtnClickType_DCLDD = 14,
    BtnClickType_YCLDD = 15,
    BtnClickType_KGFSZ = 16,
    BtnClickType_ZZ = 17,
    BtnClickType_EXIT = 18
};

@interface ZQMainPage ()
@property (weak, nonatomic) IBOutlet UILabel *userNameLabel;
@property (weak, nonatomic) IBOutlet UILabel *permissionLevelLabel;
@property (weak, nonatomic) IBOutlet UIView *glyLeftView;
@property (weak, nonatomic) IBOutlet UILabel *glyLabel;
@property (weak, nonatomic) IBOutlet ZQFastBtn *dclddBtn;
@property (weak, nonatomic) IBOutlet ZQFastBtn *yclddBtn;
@property (weak, nonatomic) IBOutlet ZQFastBtn *myAdressBtn;
@property (weak, nonatomic) IBOutlet ZQFastBtn *kgfBtn;
@property (weak, nonatomic) IBOutlet UIView *cjglyView;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *kgfConstraintCenterY;
@property (weak, nonatomic) IBOutlet ZQFastBtn *superAdressBtn;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *superConstraintCenterY;
@property (weak, nonatomic) IBOutlet UIView *adminView;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *adminTop;

/** listArr */
@property (nonatomic, copy) NSArray *listNameArr;
@end

@implementation ZQMainPage

- (NSArray *)listNameArr
{
    if (!_listNameArr) {
        _listNameArr = [[NSArray alloc] initWithObjects:@"管理员设置",@"币种管理",@"我的地址",@"我的地址",@"待处理订单",@"已处理订单",@"矿工费设置",@"转账",nil];
    }
    return _listNameArr;
}


- (IBAction)mianBtnClick:(UIButton *)sender {
    switch (sender.tag) {
        case BtnClickTypeS_GLYSZ:
            [self pushSetting:sender vcController:[ZQAdminSetting new]];
            break;
        case BtnClickTypeS_BZGL:
            [self pushSetting:sender vcController:[ZQMoneyManger new]];
            break;
        case BtnClickTypeS_WDDZ:
            [self pushSetting:sender vcController:[ZQMyAdressPage new]];
            break;
        case BtnClickType_DCLDD:
            [self pushSetting:sender vcController:[ZQPendingOrderPage new]];
            break;
        case BtnClickType_YCLDD:
            [self pushSetting:sender vcController:[ZQProcessedOrderPage new]];
            break;
        case BtnClickType_WDDZ:
            [self pushSetting:sender vcController:[ZQMyAdressPage new]];
            break;
        case BtnClickType_KGFSZ:
            [self pushSetting:sender vcController:[ZQKFeeSettingPage new]];
            break;
        case BtnClickType_EXIT:
            [self.navigationController popViewControllerAnimated:YES];
            [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"Username"];
            break;
        case BtnClickType_ZZ:
            [self pushSetting:sender vcController:[ZQZZPage new]];
            break;
        default:
            break;
    }
}

- (void)pushSetting:(UIButton *)sender  vcController:(UIViewController *)vcController
{
    vcController.title = self.listNameArr[sender.tag - 10];
    [[ZQ_GetCurrentViewNavTool currentNC] pushViewController:vcController animated:YES];
}

- (void)viewDidLoad {
    [super viewDidLoad];
 
    //存入数组并同步
    [[NSUserDefaults standardUserDefaults] setObject:self.saveModel.Username forKey:@"Username"];
    
    [[NSUserDefaults standardUserDefaults] synchronize];
    
//    //读取存入的数组 打印
//    
//    NSArray *arr = [[NSUserDefaults standardUserDefaults] objectForKey:@"mutableArr"];
//    
    
    [self setUpNavBar];
    
    if (self.saveModel.Id == 1) {
        self.permissionLevelLabel.text = @"超级管理员";
        // 显示超级管理员
        self.adminView.alpha = 0;
    } else {
        self.permissionLevelLabel.text = @"普通管理员";
        self.cjglyView.alpha = 0;
        self.adminTop.constant -= self.cjglyView.height;
    }

    self.userNameLabel.text = self.saveModel.Username;
}

- (void)setUpNavBar
{
    self.navigationItem.leftBarButtonItem = [UIBarButtonItem backItemWithImage:nil hightImage:nil target:self action:@selector(editClick) title:@""];
    // titleview search_big searchWorkInfo
    //    self.navigationItem.title =  @"首页";
}

- (void)editClick
{
    
}


@end
